package com.java.control;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.java.bean.UserInfoBean;
import com.java.model.UserInfoModel;
import com.java.utils.EasyFactory;
import com.java.utils.MyUtils;

@WebServlet("/UserInfoQueryingControl")
public class UserInfoQueryingControl extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {		
		// 将表单转换为参数实体类
		UserInfoBean userInfoB = MyUtils.convertRequest2BeanWithFileUpload(request, UserInfoBean.class);
		// 调用Medol进行业务逻辑
		List<UserInfoBean> lst = EasyFactory.getNewInstance(UserInfoModel.class).queryUserInfoByParams(userInfoB);
		// 根据业务逻辑结果进行显示页面跳转处理
		// 将查询的结果集缓存到session对象中
		request.getSession().setAttribute("lstQueryUserInfos", lst);
		// 转发到查询成功页面
		request.getRequestDispatcher("WEB-INF/pages/userInfo/UserInfoQuery.jsp").forward(request, response);

	}

}
